package com.grass.cropTradingCenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.grass.cropTradingCenter.pojo.entity.GoodsPackage;
import com.grass.cropTradingCenter.service.GoodsPackageService;
import com.grass.cropTradingCenter.mapper.GoodsPackageMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author zipan
* @description 针对表【goods_package】的数据库操作Service实现
* @createDate 2024-03-05 13:30:38
*/
@Service
public class GoodsPackageServiceImpl extends ServiceImpl<GoodsPackageMapper, GoodsPackage>
    implements GoodsPackageService{

    @Override
    public List<GoodsPackage> getPackageList(int goodsId) {
        return this.list(new LambdaQueryWrapper<GoodsPackage>().eq(GoodsPackage::getGoodsId, goodsId));
    }

    @Override
    public void removePackagesByGoodsId(int goodsId) {
        this.remove(new LambdaQueryWrapper<GoodsPackage>().eq(GoodsPackage::getGoodsId, goodsId));
    }

    @Override
    public void savePackages(int goodsId, List<GoodsPackage> packages) {
        for (GoodsPackage goodsPackage : packages) {
            goodsPackage.setGoodsId(goodsId);
        }
        this.saveBatch(packages);
    }
}




